package com.xiaocui.utils;

import com.xiaocui.domain.Point;
import org.apache.log4j.Logger;

/**
 * 84坐标系和火星坐标系互转
 */
public class TransformPointer_84tomars {
	private static final Logger log = Logger.getLogger(TransformPointer_84tomars.class);

	/**
	 * 火星坐标系转换为84坐标系
	 * 
	 * @param pointgcj
	 * @return
	 */
	public static Point GcjToWsgTransform(Point pointgcj) {

		try {
			GCJPointer gcjpointer = new GCJPointer(pointgcj.getLat(), pointgcj.getLng());
			WSGPointer wsgpointer = gcjpointer.toWSGPointer();
			double latwsg = wsgpointer.getLatitude();
			double lgtwsg = wsgpointer.getLongitude();
			Point point = new Point(lgtwsg, latwsg);
			return point;
		} catch (Exception e) {
			log.error(e);
		}

		return null;
	}

	/**
	 * 84坐标系转换为火星坐标系
	 * 
	 * @return
	 */
	public static Point WsgToGcjTransform(Point point84) {
		try {
			WSGPointer wsgpoint = new WSGPointer(point84.getLat(), point84.getLng());
			GCJPointer gcjpoint = wsgpoint.toGCJPointer();
			Point point = new Point(gcjpoint.getLongitude(), gcjpoint.getLatitude());
			return point;
		} catch (Exception e) {
			log.error(e);
		}
		return null;
	}
}
